package com.klod.news.widget

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import coil3.compose.AsyncImage
import coil3.request.ImageRequest
import coil3.request.crossfade
import com.klod.news.R

@Composable
fun NetworkImage(
    modifier: Modifier = Modifier,
    url: Any,
    contentDescription: String = "",
    contentScale: ContentScale = ContentScale.Crop,
    placeholder: Int = R.mipmap.placeholder,
    crossFade: Boolean = true
){
    AsyncImage(
        model = ImageRequest.Builder(LocalContext.current)
            .data(url)
            .crossfade(crossFade)
            .build(),
        placeholder = painterResource(placeholder),
        contentDescription = contentDescription,
        contentScale = contentScale,
        modifier = modifier,
    )
}